package com.cn.evaluate.handler;

import java.util.List;

import org.apache.log4j.Logger;
import org.dom4j.DocumentException;
import org.dom4j.Element;

/**
 * 项目处理器
 * 
 * @author Admin
 * 
 */
public class SubjectHandler extends DefaultHandler {

	/**
	 * 日志
	 */
	private static Logger logger = Logger.getLogger(SubjectHandler.class);

	/**
	 * 使用示例:给出年级、性别、科目类型（体育教学项目、体质测评项目）即可列出项目名称等
	 * 
	 * @param args
	 * @throws DocumentException
	 */
	public static void main(String[] args) throws DocumentException {
		SubjectHandler handler = new SubjectHandler(
				"src/com/cn/evaluate/resource/subject.xml");
		String xpath = "/subjects/subject[@grade='1' and @type='j']";
		List<?> result = handler.getElement(handler.getRootElement(), xpath);

		logger.debug("result:" + result.size());
		for (int i = 0; i < result.size(); ++i) {
			Element element = (Element) result.get(i);
			logger.debug(element.attribute("description").getValue());
			logger.debug(element.attribute("ruler").getValue());
			logger.debug(element.attribute("type").getValue());
			logger.debug("=================");
		}
	}

	/**
	 * 构造函数
	 * 
	 * @param xmlFilePath
	 */
	public SubjectHandler(String xmlFilePath) {
		super(xmlFilePath);
	}

}
